---
id: kubernetes
title: Install with Kubernetes
description: Installation and deployment instructions for using Kubernetes deploy a Tracetest Agent and use the Cloud-based managed Tracetest Control Plane / Dashboard.
hide_table_of_contents: true
keywords:
  - tracetest
  - tracetest cli install
  - tracetest cloud install
  - tracetest agent install
  - trace-based testing
  - observability
  - distributed tracing
  - testing
image: https://res.cloudinary.com/djwdcmwdz/image/upload/v1698686403/docs/Blog_Thumbnail_14_rsvkmo.jpg
---

This guide explains how to install a Tracetest Agent in your Kubernetes environment. This deployment uses the Cloud-based managed Tracetest Control Plane and Dashboard.

## Prerequisites

- A running Kubernetes cluster.
- Install [`kubectl`](https://kubernetes.io/docs/tasks/tools/#kubectl).
- [Sign in to Tracetest](https://app.tracetest.io/) and retrieve your [Tracetest Organization API Key/Token and Environment ID](https://app.tracetest.io/retrieve-token).


## Install the Tracetest Agent with Kubernetes

[Tracetest Agent](/concepts/agent) runs as a Kubernetes Deployment with a Service.

```yaml title="tracetest-agent.yaml"
---
# Service
apiVersion: v1
kind: Service
metadata:
  name: tracetest-agent
  labels:
    app.kubernetes.io/name: tracetest-agent
    app.kubernetes.io/instance: tracetest-agent
spec:
  selector:
    app.kubernetes.io/name: tracetest-agent
    app.kubernetes.io/instance: tracetest-agent
  ports:
    - name: grpc-collector-entrypoint
      protocol: TCP
      port: 4317
      targetPort: 4317
    - name: http-collector-entrypoint
      protocol: TCP
      port: 4318
      targetPort: 4318
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tracetest-agent
  labels:
    app: tracetest-agent
    app.kubernetes.io/name: tracetest-agent
    app.kubernetes.io/instance: tracetest-agent
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: tracetest-agent
      app.kubernetes.io/instance: tracetest-agent
  template:
    metadata:
      labels:
        app.kubernetes.io/name: tracetest-agent
        app.kubernetes.io/instance: tracetest-agent
    spec:
      containers:
        - name: agent
          image: "kubeshop/tracetest-agent:latest"
          imagePullPolicy: Always
          args: [
            "--environment",
            "<TRACETEST_ENVIRONMENT_ID>", # Add your env id
            "--api-key",
            "$TRACETEST_API_KEY",
            "--server-url",
            "https://app.tracetest.io",
          ]
          env:
          - name: TRACETEST_API_KEY
            value: "<TRACETEST_API_KEY>" # Add your API key
```

```bash title="Terminal"
kubectl apply -f ./tracetest-agent.yaml
```

The Tracetest Agent is running in Kubernetes and ready to accept traces.

gRPC: `http://tracetest-agent.default.svc.cluster.local:4317`

HTTP: `http://tracetest-agent.default.svc.cluster.local:4318/v1/traces`

:::note K8s Network
Make sure to check use the correct `<service-name>` if you edit the Tracetest Agent `service` name.

Running a test against `localhost` will resolve as `127.0.0.1` inside the Tracetest Agent container.
Make sure to run tests using the internal Kubernetes service networking eg: `http://api.default.svc.cluster.local:port`.
:::
